/*
 * @Author: xurenda <xurenda@qq.com>
 * @HomePage: https://xurenda.top
 * @Github: https://github.com/xurenda
 * @Date: 2019-10-12 20:46:44
 * @LastEditTime: 2019-12-06 21:50:57
 * @FilePath: \elegant-surf\src\store\index.js
 */
import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'
import mutations from './mutations'
import actions from './actions'
import { backgroundColors } from '@/assets/js/data'

Vue.use(Vuex)

// 默认数据
const state = {
  // 通用设置
  commonSetting: {
    language: 'chinese'
  },
  // 搜索设置
  searchSetting: {
    defaultEngine: 'baidu'
  },
  // 外观设置
  appearanceSetting: {
    theme: 'light',
    rounded: true
  },
  // 背景
  background: {
    isColor: false,
    color: '#ededed',
    sketch: 'waves',
    colors: backgroundColors
  },
  // 首页日常书签
  dailyMarks: [
    { name: 'B站', url: '//www.bilibili.com/', icon: '//www.bilibili.com/favicon.ico' },
    { name: '知乎', url: '//www.zhihu.com/', icon: '//www.zhihu.com/favicon.ico' },
    { name: '语雀', url: '//www.yuque.com/', icon: '//gw.alipayobjects.com/zos/rmsportal/UTjFYEzMSYVwzxIGVhMu.png' },
    { name: '阿里巴巴矢量图标库', url: '//www.iconfont.cn/', icon: '//www.iconfont.cn/favicon.ico' },
    { name: '码云', url: '//gitee.com/', icon: '//gitee.com/favicon.ico' },
    { name: 'github', url: '//github.com/', icon: '//github.com/favicon.ico' }
  ]
}

export default new Vuex.Store({
  state,
  mutations,
  actions,
  plugins: [createPersistedState()] // 数据持久化：储存到localStorage
})
